<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改用户关联')"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-user-edit" th:object="${wxUser}">
        <input name="userId" th:field="*{userId}" type="hidden">
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">OPENID：</label>
            <div class="col-sm-10">
                <input name="openid" id="openid" th:field="*{openid}" class="form-control" type="text" readonly required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">用户名称：</label>
            <div class="col-sm-10">
                <input name="userName" id="userName" th:field="*{userName}" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">用户头像：</label>
            <div class="col-sm-10">
                <input id="userPic" th:value="*{userPic}" type="hidden">
                <div class="upload" action='upload.html' data-num="1" data-value='' id='piclist_userPic'></div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">联系方式：</label>
            <div class="col-sm-10">
                <input name="userPhone" id="userPhone" th:field="*{userPhone}" class="form-control" type="text"
                       required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">用户角色：</label>
            <div class="col-sm-8" th:with="type=${@dict.getType('user_type')}">
                <label th:each="dict : ${type}" class="check-box">
                    <input disabled name="userType" type="checkbox" th:value="${dict.dictValue}" th:text="${dict.dictLabel}"  th:checked="${!#lists.isEmpty(wxUser.userType) && #arrays.contains(wxUser.userType, dict.getDictValue())}"  >
                </label>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script type="text/javascript">
    var prefix = ctx + "wechat/user";


    $("#form-user-edit").validate({
        focusCleanup: true
    });


    //轮播图上传
    $("#piclist_userPic").attr("data-value", $("#userPic").val())
    $("#piclist_userPic").upload(function () {
    }, "userPic")


    $("input[name='userTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });


    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-user-edit').serialize());
        }
    }
</script>
</body>
</html>
